package com.example.rydwlib.adapter

import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.example.rydwlib.R
import com.example.rydwlib.bean.RyRegionData

class RyRegionAdapter(layoutResId: Int, data: List<List<RyRegionData>>?) :
    BaseQuickAdapter<List<RyRegionData>, BaseViewHolder>(layoutResId, data) {

    override fun convert(helper: BaseViewHolder, item: List<RyRegionData>) {
        if (item.isEmpty()) return
        helper.setText(R.id.ry_item_region_type, item[0].regiontype)
        val layoutManager = LinearLayoutManager(mContext)
        layoutManager.orientation = LinearLayoutManager.VERTICAL
        val recyclerView = helper.getView<RecyclerView>(R.id.ry_item_region_more_rcy)
        recyclerView.layoutManager = layoutManager
        val moreAdaptr = RegionMoreAdapter(R.layout.ry_region_more_item, item)

        recyclerView.adapter = moreAdaptr
    }

    internal inner class RegionMoreAdapter(layoutResId: Int, data: List<RyRegionData>?) :
        BaseQuickAdapter<RyRegionData, BaseViewHolder>(layoutResId, data) {

        override fun convert(helper: BaseViewHolder, item: RyRegionData) {
            helper.setText(R.id.item_region_name, item.regionname)
                .setText(R.id.item_region_count, item.regioncheckpersonnum.toString())
                .setText(R.id.item_region_reality, item.regioncount.toString())
        }
    }
}
